﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Ad_HinhAnhUC.ascx.cs" Inherits="GUI.Admin.uc.Ad_HinhAnhUC" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<style type="text/css">
    .style2
    {
        color: Blue;
        font-size: 25px;
        margin-left: 50px;
    }
    
    .style3
    {
        color: Red;
        font-weight: bold;
    }
    
    .tb_left
    {
        width: 15%;
    }
    
    .tb_center
    {
        width: 20%;
    }
    
    .tb_right
    {
        width: 85%;
    }
    
    .style4
    {
        color: #FF0000;
    }
</style>
<script type="text/javascript" language="javascript">
    function changeCheckState() {
        try {
            var frm = document.forms[0];
            var i = 0;
            for (i = 0; i < frm.length; i++) {
                if (frm.elements[i].id.indexOf('CheckBoxItem') != -1) {
                    if (document.getElementById(frm.elements[i].id) != null) {
                        if (frm.elements[i].checked == false) {
                            frm.elements[i].checked = true;
                        } else {
                            frm.elements[i].checked = false;
                        }
                    }
                }
            }
        } catch (err) { }
    }
</script>
<table style="width: 100%; border: 1px solid #008000;">
    <tr>
        <td colspan="2">
            <asp:ImageButton ID="ButtonTroLai" runat="server" ImageUrl="~/Admin/images/back_f2.png"
                OnClick="ButtonTroLai_Click" ToolTip="Trở lại" />
            <asp:Label ID="LabelTitle" runat="server" CssClass="style2" Text="Quản lý hình ảnh sản phẩm"></asp:Label>
        </td>
        <td rowspan="9" class="tb_center">
            <asp:Image ID="ImageHinhAnhMacDinh" runat="server" BorderStyle="Solid" Height="250px"
                Width="200px" />
        </td>
    </tr>
    <tr>
        <td class="tb_left">
            &nbsp;
        </td>
        <td>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td>
            <asp:FileUpload ID="FileUploadHinhAnh" runat="server" ToolTip="Chọn hình" EnableTheming="True"
                Width="250px" />
        </td>
        <td>
            <asp:RequiredFieldValidator ID="RequiredFieldValidatorHinhAnh" runat="server" ControlToValidate="FileUploadHinhAnh"
                Display="Dynamic" ErrorMessage="(*) Bạn chưa chọn ảnh nào !" SetFocusOnError="True"
                ValidationGroup="Nhap"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="(*) File ảnh chưa đúng định dạng !"
                ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.jpg|.JPG|.gif|.GIF|.png|.PNG)$"
                ControlToValidate="FileUploadHinhAnh" Display="Dynamic"></asp:RegularExpressionValidator>
            <asp:Label ID="LabelFileSize" runat="server" ForeColor="Red"></asp:Label>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            Lưu ý: Chỉ được upload hình theo định dạng: <span class="style3">*.jpg, *.gif, *.png</span>
            và kích thước tối đa <span class="style3">3MB</span>.
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
        <td>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td>
            <asp:CheckBox ID="CheckBoxDefault" runat="server" Font-Bold="False" Text="Chọn làm hình đại diện"
                ToolTip="Chọn làm hình đại diện" />
        </td>
        <td>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
        <td>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td>
            <asp:Button ID="ButtonLuu" runat="server" OnClick="btnLuu_Click" Text="Lưu" ToolTip="Lưu lại"
                ValidationGroup="Nhap" Width="80px" />
        </td>
        <td>
            <asp:HiddenField ID="HiddenFieldMaSanPham" runat="server" Visible="False" />
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
        <td>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
        <td>
            <span class="style4">Tổng số hình ảnh cho sản phẩm này: </span>&nbsp;
            <asp:Label ID="LabelTongSoHinhAnh" runat="server" Text="" CssClass="style3">
            </asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <asp:ImageButton ID="ImageButtonXoa" runat="server" CommandName="Delete" ImageUrl="~/Admin/images/delete.png"
                ToolTip="Xóa ảnh này" 
                OnClientClick="return confirm('Bạn có muốn xóa thật không?');" 
                onclick="ImageButtonXoa_Click" />
        </td>
        <td>
            &nbsp;
        </td>
        <td>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td class="tb_left" colspan="3">
            <asp:GridView ID="GridViewHinhAnh" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                CellPadding="4" ForeColor="#333333" Width="100%" 
                EnableModelValidation="True" OnPageIndexChanging="GridViewHinhAnh_PageIndexChanging"
                OnRowDataBound="GridViewHinhAnh_RowDataBound" PageSize="5">
                <RowStyle BackColor="#EFF3FB" />
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:CheckBox ID="CheckBoxAll" runat="server" ToolTip="Check all" onclick="changeCheckState(this);" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="CheckBoxItem" runat="server" ToolTip="Check" />
                        </ItemTemplate>
                        <HeaderStyle Width="20px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="ID">
                        <ItemTemplate>
                            <asp:Label ID="LabelMaHinhAnh" runat="server" Text='<%# Eval("MaHinhAnh") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle Width="20px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Mã sản phẩm">
                        <ItemTemplate>
                            <asp:Label ID="LabelMaSanPham" runat="server" Text='<%# Eval("MaSanPham") %>'></asp:Label>
                        </ItemTemplate>
                        <HeaderStyle Width="120px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Hình ảnh">
                        <ItemTemplate>
                            <asp:Image ID="Image1" runat="server" ImageUrl='<%# "~/Images/" + Eval("TenHinhAnh") %>'
                                Height="120px" Width="100px" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#2461BF" />
                <AlternatingRowStyle BackColor="White" />
            </asp:GridView>
        </td>
    </tr>
</table>
